<!DOCTYPE html>
<?php
//Datenbank einstellungen laden
include("conf/conf.php");
$dbConf = new Conf();
$databaseURL = $dbConf->get_databaseURL();
$databaseUName = $dbConf->get_databaseUName();
$databasePWord = $dbConf->get_databasePWord();
$databaseName = $dbConf->get_databaseName();
?>
<html>
    <head>
        <title>TU Braunschweig mobil</title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <meta name="viewport" content="width=device-width; initial-scale=1; maximum-scale=1; user-scalable=no;">
        <link rel="shortcut icon" href="themes/images/tubs_favicon.png" />
        <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.css" />
        <link rel="stylesheet" href="themes/TU-BS.css" />
        <script type="text/javascript" src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
        <script type="text/javascript" src="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.js"></script>
    </head>

    <body>
        <div data-role="page" id="termine">
            <div data-role="header">
                <div class="ui-grid-b">
                    <div class="ui-block-a">
                        <div id="header">
                            <a href="index-mobile.php" data-ajax="false"><img src="themes/images/siegel.png" width="71" height="72" alt="TU Siegel"></a>
                        </div>
                    </div>
                    <div class="ui-block-b">
                        <div id="crumb">
                            <a href="termine.php" data-ajax="false"><img src="themes/images/83-calendar@2xw.png" height="36px" width="48px"></a>
                        </div>
                    </div>
                    <div class="ui-block-c">
                        <div id="crumb">
                            <img src="themes/images/179-notepad@2xw.png" height="36px" width="48px">
                        </div>
                    </div>
                </div>
                <div style="clear: both"></div>
            </div>
            <div data-role="content" data-theme="b">
                <div data-role="collapsible-set" data-theme="a">
                    <?php
                    $year = getdate();
                    if ($year["month"] > 3 and $year["month"] < 11) {
                        $yearstring = "Sommersemester " . $year["year"];
                    } else {
                        $yearstring = "Wintersemester " . ($year["year"] - 1) . "/" . $year["year"];
                    }
                    $connection = mysql_connect($databaseURL, $databaseUName, $databasePWord)
                            or die("Error while connecting to localhost");
                    $db = mysql_select_db($databaseName, $connection)
                            or die("Error while connecting to database");

                    $sql = "SELECT * FROM semestertermine";

                    $res = mysql_query($sql) or die("Error while connecting to database");

                    while ($row = mysql_fetch_object($res)) {
                        if ($yearstring == $row->semesterjahr) {
                            echo "<div data-role='collapsible' data-content-theme='a' data-collapsed='false'><h3>$row->semesterjahr</h3>";
                            echo "<p>" . $row->termine . "<br><a href='" . $row->idsemestertermine . ".php' data-ajax='false'>Kalender Import</a></p></div>";
                        } else {
                            echo "<div data-role='collapsible' data-content-theme='a'><h3>$row->semesterjahr</h3>";
                            echo "<p>" . $row->termine . "<a href='" . $row->idsemestertermine . ".php' data-ajax='false'>Kalender Import</a></p></div>";
                        }
                    }
                    ?>
                </div>
            </div>
        </div>
    </body>
</html>